What does this `_time_independent_equlas` mean?

Posted by Satoru.Logic on Stack Overflow See other posts from Stack Overflow or by Satoru.Logic
Published on 2010-06-12T02:52:45Z Indexed on 2010/06/12 3:02 UTC
Read the original article Hit count: 202

Filed under:
|

In the tornado.web module there is a function called _time_independent_equals:

def _time_independent_equals(a, b):
    if len(a) != len(b):
        return False
    result = 0
    for x, y in zip(a, b):
        result |= ord(x) ^ ord(y)
    return result == 0

It is used to compare secure cookie signatures, and thus the name.

But regarding the implementation of this function, is it just a complex way to say a==b?

© Stack Overflow or respective owner

Related posts about python

Related posts about tornado